#include "stuinfo.h"
int Read_file(struct Stu *stu1, int *pn) // 从文件stuscore.dat中读取数据
{
	FILE *fp = fopen("stuscore.dat", "r");
	if (fp == NULL)
	{
		perror("fopen");
		return 0;
	}
	int n = 0;
	while (1)
	{
		if (fscanf(fp, "%s %s %d %d,%d %d,%d %d\n", stu1[n].id, stu1[n].name, &stu1[n].grades[0].score, &stu1[n].grades[0].credit, &stu1[n].grades[1].score, &stu1[n].grades[1].credit, &stu1[n].grades[2].score, &stu1[n].grades[2].credit) == EOF) // 判断文件结束
			break;
		n++;
	}
	fclose(fp);
	fp = NULL;
	*pn = n;
	return 1;
}
void Show(struct Stu *stu1, int n) // 在屏幕上显示
{
	int i = 0;
	printf("     id     name   score&credit\n");
	for (i = 0; i < n; i++)
	{
		printf("%s ", stu1[i].id);
		printf("%s ", stu1[i].name);
		printf("%d&%d , %d&%d , %d&%d\n", stu1[i].grades[0].score, stu1[i].grades[0].credit, stu1[i].grades[1].score, stu1[i].grades[1].credit, stu1[i].grades[2].score, stu1[i].grades[2].credit); // 百分制成绩与对应学分之间用&连接，每组之间用,分隔
	}
}